import 'package:flutter/material.dart';

class NeuBox extends StatelessWidget {
  //子元素
  final Widget child;

  //盒子宽度
  final double? width;

  //盒子高度
  final double? height;

  //内边距
  final EdgeInsetsGeometry? padding;

  //外边距
  final EdgeInsetsGeometry? margin;

  //自定义圆角（可分别定义4个角的弧度）
  final BorderRadiusGeometry? borderRadius;

  //圆角大小（默认4个角的弧度）
  final double? borderRadiusSize;

  //盒子背景颜色
  final Color? backgroundColor;

  //光源颜色
  final Color? lightColor;

  //光源偏移量
  final Offset? lightOffset;

  //阴影颜色
  final Color? shadowColor;

  //阴影偏移量
  final Offset? shadowOffset;

  //光源、阴影的模糊半径
  final double? blurRadius;

  const NeuBox({
    Key? key,
    required this.child,
    this.width,
    this.height,
    this.padding,
    this.margin,
    this.borderRadius,
    this.borderRadiusSize,
    this.backgroundColor,
    this.lightColor,
    this.lightOffset,
    this.shadowColor,
    this.shadowOffset,
    this.blurRadius,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Container(
      width: width,
      height: height,
      padding: padding ?? const EdgeInsets.all(8),
      margin: margin,
      decoration: BoxDecoration(
          color: backgroundColor ?? Colors.grey[300],
          borderRadius:
              borderRadius ?? BorderRadius.circular(borderRadiusSize ?? 12),
          boxShadow: [
            BoxShadow(
                color: shadowColor ?? Colors.grey.shade500,
                blurRadius: blurRadius ?? 15,
                offset: shadowOffset ?? const Offset(5, 5)),
            BoxShadow(
                color: lightColor ?? Colors.white,
                blurRadius: blurRadius ?? 15,
                offset: lightOffset ?? const Offset(-5, -5))
          ]),
      child: child,
    );
  }
}
